//package com.yupi.ojsystem.controller;
//
//
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.yupi.ojsystem.common.BaseResponse;
//import com.yupi.ojsystem.common.ErrorCode;
//import com.yupi.ojsystem.common.ResultUtils;
//import com.yupi.ojsystem.exception.BusinessException;
//import com.yupi.ojsystem.model.dto.questionsubmit.QuestionSubmitAddRequest;
//import com.yupi.ojsystem.model.dto.questionsubmit.QuestionSubmitQueryRequest;
//import com.yupi.ojsystem.model.entity.QuestionSubmit;
//import com.yupi.ojsystem.model.entity.User;
//import com.yupi.ojsystem.model.vo.QuestionSubmitVO;
//import com.yupi.ojsystem.service.IQuestionSubmitService;
//import com.yupi.ojsystem.service.UserService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//
///**
// * <p>
// * 题目提交 前端控制器
// * </p>
// *
// * @author k
// * @since 2025-04-04
// */
//@RestController
//@RequestMapping("/question-submit")
//@Api("题目提交相关接口")
//public class QuestionSubmitController {
//
//    @Resource
//    private IQuestionSubmitService questionSubmitService;
//
//    @Resource
//    private UserService userService;
//
//    /**
//     * 提交题目
//     *
//     * @param questionSubmitAddRequest
//     * @param request
//     * @return 提交记录id
//     */
//    @PostMapping("/")
//    @ApiOperation("提交题目")
//    public BaseResponse<Long> doQuestionSumit(@RequestBody QuestionSubmitAddRequest questionSubmitAddRequest,
//                                              HttpServletRequest request) {
//        if (questionSubmitAddRequest == null || questionSubmitAddRequest.getQuestionId() <= 0) {
//            throw new BusinessException(ErrorCode.PARAMS_ERROR);
//        }
//        // 登录才能点赞
//        final User loginUser = userService.getLoginUser(request);
//        long questionId = questionSubmitAddRequest.getQuestionId();
//        long questionSubmitId = questionSubmitService.doQuestionSubmit(questionSubmitAddRequest, loginUser);
//        return ResultUtils.success(questionSubmitId);
//    }
//    /**
//     * 分页获取题目提交列表（仅管理员）
//     *
//     * @param questionSubmitQueryRequest
//     * @return
//     */
//    @PostMapping("/list/page")
//    @ApiOperation("分页获取题目提交列表（仅管理员）")
//    public BaseResponse<Page<QuestionSubmitVO>> listQuestionSubmitByPage(@RequestBody QuestionSubmitQueryRequest questionSubmitQueryRequest, HttpServletRequest request) {
//        long current = questionSubmitQueryRequest.getCurrent();
//        long size = questionSubmitQueryRequest.getPageSize();
//        //从数据提取到原始的分页信息
//        Page<QuestionSubmit> questionSubmitPage = questionSubmitService.page(new Page<>(current, size),
//                questionSubmitService.getQueryWrapper(questionSubmitQueryRequest));
//        final User loginUser=userService.getLoginUser(request);
//        //返回脱敏信息
//        return ResultUtils.success(questionSubmitService.getQuestionSubmitVOPage(questionSubmitPage,loginUser));
//    }
//}
//
